package belf.migrate.engine.job;

import belf.migrate.api.job.JobCode;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * 每个一数据库对象操作结果，如创建一张表、删除一张表索引、创建一个视图、创建一个Type等子任务的执行结果。
 */
@Slf4j
public class JobResultItem {
    /** 源数据库对象名称，可以是表名、视图名、外键名等 */
    private String sourceObjectName;
    /** 目标数据库对象名称，可以是表名、视图名、外键名等 */
    private String sinkObjectName;

    /** 执行结果代码，参考{@link JobCode} */
    private int code;
    /** 本次操作的提升信息 */
    private String message;
    /** 异常的堆栈信息 */
    private String errors;
    /** 如果job是执行DDL语句，出错时可以将DDL返回 */
    private String sourceDdl;

    private String sinkDdl;

    private String type;

    private String startTime;

    private String endTime;

    private String errorTips;
    /** 大模型给出的本次SQL转化的理由 */
    private List<String> reasons;

    public JobResultItem(String sourceObjectName, String sinkObjectName, int code, String message) {
        this.sourceObjectName = sourceObjectName;
        this.sinkObjectName = sinkObjectName;
        this.code = code;
        this.message = message;
    }

    public JobResultItem(String sourceObjectName,
                         String sinkObjectName,
                         int code,
                         String message,
                         String errors,
                         String type,
                         String startTime,
                         String endTime,
                         String sourceDdl,
                         String sinkDdl) {
        this.sourceObjectName = sourceObjectName;
        this.sinkObjectName = sinkObjectName;
        this.code = code;
        this.message = message;
        this.errors = errors;
        this.type = type;
        this.startTime = startTime;
        this.endTime = endTime;
        this.sourceDdl = sourceDdl;
        this.sinkDdl = sinkDdl;
    }

    public JobResultItem(String sourceObjectName,
                         String sinkObjectName,
                         int code,
                         String message,
                         String errors,
                         String type,
                         String startTime,
                         String endTime,
                         String sourceDdl,
                         String sinkDdl,
                         String errorTips) {
        this.sourceObjectName = sourceObjectName;
        this.sinkObjectName = sinkObjectName;
        this.code = code;
        this.message = message;
        this.errors = errors;
        this.type = type;
        this.startTime = startTime;
        this.endTime = endTime;
        this.sourceDdl = sourceDdl;
        this.sinkDdl = sinkDdl;
        this.errorTips = errorTips;
    }

    public String getSourceObjectName() {
        return sourceObjectName;
    }

    public void setSourceObjectName(String sourceObjectName) {
        this.sourceObjectName = sourceObjectName;
    }

    public String getSinkObjectName() {
        return sinkObjectName;
    }

    public void setSinkObjectName(String sinkObjectName) {
        this.sinkObjectName = sinkObjectName;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public String getErrors() {
        return errors;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setErrors(String errors) {
        this.errors = errors;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getSourceDdl() {
        return sourceDdl;
    }

    public void setSourceDdl(String sourceDdl) {
        this.sourceDdl = sourceDdl;
    }

    public String getSinkDdl() {
        return sinkDdl;
    }

    public void setSinkDdl(String sinkDdl) {
        this.sinkDdl = sinkDdl;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getErrorTips() {
        return errorTips;
    }

    public void setErrorTips(String errorTips) {
        this.errorTips = errorTips;
    }

    public List<String> getReasons() {
        return reasons;
    }

    public void setReasons(List<String> reasons) {
        this.reasons = reasons;
    }

    @Override
    public String toString() {
        return "JobResultItem{" +
                "sourceObjectName='" + sourceObjectName + '\'' +
                "sinkObjectName='" + sinkObjectName + '\'' +
                ", code=" + code +
                ", message='" + message + '\'' +
                ", errors='" + errors + '\'' +
                '}';
    }
}
